<template>
  <div class="tabbar" catchtouchmove="move">
      <div class="tabbar-list">
        <div class="tabbar-item" @click="tabToIndex">
          <div class="tabbar-icon">
            <img v-if="curTabActive==='INDEX'" src="/static/images/ic_tabs_allbooks_selected.png" alt="">
            <img v-else src="/static/images/ic_tabs_allbooks_normal.png" alt="">
          </div>
          <div v-bind:class="[curTabActive==='INDEX'?'tabbar-active':'tabbar-txt']">书架</div>
        </div>
        <div class="tabbar-item" @click="tabToGroup">
          <div class="tabbar-icon">
            <img v-if="curTabActive==='GROUP'" src="/static/images/ic_tabs_group_selected.png" alt="">
            <img v-else src="/static/images/ic_tabs_group_normal.png" alt="">
          </div>
          <div v-bind:class="[curTabActive==='GROUP'?'tabbar-active':'tabbar-txt']">小组</div>
        </div>
        <div class="tabbar-item" @click="tabToUser">
          <div class="tabbar-icon">
            <img v-if="curTabActive==='USER'" src="/static/images/ic_tabs_usercenter_selected.png" alt="">
            <img v-else src="/static/images/ic_tabs_usercenter_normal.png" alt="">
          </div>
          <div  v-bind:class="[curTabActive==='USER'?'tabbar-active':'tabbar-txt']">我的</div>
        </div>
      </div>
    </div>
</template>

<script>
  export default {
    props: ['tabConstant'],
    computed: {
      curTabActive () {
        return this.tabConstant
      },
      isShowTabbar () {
        return this.$isHideTabBar
      },
      tabbarPaddingBottom () {
        return this.$tabBarPaddingBottom
      }
    },
    mounted(){
      console.log(`tabbar${this.tabConstant}`)
      // 隐藏tabbar
        wx.hideTabBar({})

    },
    methods: {
      tabToIndex () {
        console.log(`INDEX`)

        wx.switchTab({
          url: '/pages/index/main'
        })
      },
      tabToGroup () {
        console.log(`tabbar${this.tabConstant}`)

        wx.switchTab({
          url: '/pages/group/main'
        })
      },
      tabToUser () {
        console.log(`tabbar${this.tabConstant}`)

        wx.switchTab({
          url: '/pages/user/main'
        })
      },
    }
  };
</script>

<style lang="less" scoped>
  .tabbar {
    z-index: 1000;
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 48px;
    background-color: #ffffff;
    box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.07);
    .tabbar-list {
      display: flex;
      height: 100%;
      .tabbar-item {
        width: 33.3%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        .tabbar-icon {
          width: 25px;
          height: 25px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .tabbar-center-icon {
          position: relative;
          img {
            position: absolute;
            top: -30px;
            left: -12.5px;
            width: 50px;
            height: 50px;
            transition: all .2s ease;
            z-index: 1001;
          }
        }
        .tabbar-txt {
          font-size: 10px;
          color: #999999;
        }
        .tabbar-active {
          font-size: 10px;
          color: #1387ff;
        }
        .rotatePop {
          transform: rotate(45deg);
        }
      }
    }
    .homework-type-pop {
      z-index: 1000;
      position: fixed;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      .homework-type-mask {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, .7);
      }
      .homework-type-list {
        position: absolute;
        bottom: 150px;
        left: 0;
        right: 0;
        width: 100%;
        height: 120px;
        display: flex;
        justify-content: space-around;
        .homework-type-item {
          width: 95px;
          height: 100%;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          align-items: center;
          .icon-box {
            width: 95px;
            height: 95px;
            border-radius: 50%;
            background-color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            img.read {
              width: 46px;
              height: 44px;
            }
            img.recite {
              width: 46px;
              height: 35px;
            }
            img.customize {
              width: 43px;
              height: 46px;
            }
          }
          .icon-txt {
            font-size: 15px;
            color: #fff;
          }
        }
        .homework-type-hover {
          .icon-box {
            background-color: #ececec !important;
          }
        }
      }
    }
    .homework-first-guide {
      z-index: 999;
      position: absolute;
      top: -115px;
      left: 50%;
      width: 300px;
      margin-left: -150px;
      padding: 12px 10px;
      border-radius: 10px;
      box-sizing: border-box;
      background-color: rgba(0, 0, 0, .7);
      p {
        text-align: center;
        color: #fff;
        font-size: 18px;
      }
      .triangle {
        position: absolute;
        bottom: -7px;
        left: 50%;
        width: 0;
        height: 0;
        margin-left: -8px;
        border-style: solid;
        border-width: 8px 8px 0 8px;
        border-color: rgba(0, 0, 0, .7) transparent transparent transparent;
      }
      .closeGuideShare {
        position: absolute;
        right: 0;
        top: 0;
        width: 25px;
        height: 25px;
        display: flex;
        align-items: center;
        justify-content: center;
        img {
          display: block;
          width: 17px;
          height: 17px;
        }
      }
    }
  }
</style>
